package com.gt.web.srv.auth;
import lombok.AllArgsConstructor;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.stereotype.Component;

import java.util.Collection;
import java.util.Collections;

/**
 * All rights Reserved, Designed By www.vipthink.cn
 *
 * @Title: cc.foodism.foodism.star.api.auth JwtAuthentication
 * @Description: TDO 描述....
 * @author: Lee.Li
 * @date: 2022/3/12
 * @Copyright: www.xxoo.cn Inc. All rights reserved.
 */
@Component
@AllArgsConstructor
public class TokenAuthentication implements Authentication {


    private final JwtInfo jwtInfo;


    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return Collections.EMPTY_LIST;
    }

    @Override
    public Object getCredentials() {
        return jwtInfo;
    }

    @Override
    public Object getDetails() {
        return jwtInfo;
    }

    /**
     * UserDetails接口的实现
     * @return
     */
    @Override
    public Object getPrincipal() {
        return jwtInfo;
    }

    @Override
    public boolean isAuthenticated() {
        return false;
    }

    @Override
    public void setAuthenticated(boolean b) throws IllegalArgumentException {

    }

    /**
     * Returns the name of this principal.
     *
     * @return the name of this principal.
     */
    @Override
    public String getName() {
        return jwtInfo.getName();
    }
}
